﻿<%@ Page Language="C#" MasterPageFile="~/Web.master" AutoEventWireup="true" CodeBehind="DictValue.aspx.cs"
  Inherits="XFSale.Aux.DictValuePage" %>

<asp:Content ID="partMain" ContentPlaceHolderID="partMain" runat="server">
  <asp:SqlDataSource ID="dsDict" runat="server" ConnectionString="<%$ ConnectionStrings:txfund %>"
    ProviderName="<%$ ConnectionStrings:txfund.ProviderName %>" SelectCommand="select * from XmDictValue where upper(itemName) = upper(:itemName) order by upper(itemName), itemValue"
    InsertCommand="insert into XmDictValue(itemName, itemValue, valueOrder, valueDesc, summary) values(:itemName, :itemValue, :valueOrder, :valueDesc, :summary)"
    UpdateCommand="update XmDictValue set itemName=:itemName, itemValue=:itemValue, valueOrder=:valueOrder, valueDesc=:valueDesc, summary=:summary where itemName=:old_itemName and itemValue=:old_itemValue"
    DeleteCommand="delete from XmDictValue where itemName=:itemName and itemValue=:itemValue">
  </asp:SqlDataSource>
  <asp:SqlDataSource ID="dsItem" runat="server" ConnectionString="<%$ ConnectionStrings:txfund %>"
    ProviderName="<%$ ConnectionStrings:txfund.ProviderName %>" SelectCommand="select itemName, itemName as itemText from XmDict where itemDetail='Y' order by upper(itemName)">
  </asp:SqlDataSource>
  <asp:SqlDataSource ID="dsDictTemp" runat="server" ConnectionString="<%$ ConnectionStrings:txfund %>"
    ProviderName="<%$ ConnectionStrings:txfund.ProviderName %>"></asp:SqlDataSource>
  <table runat="server" id="pnlSearch" width="100%" class="search">
    <tr>
      <td>
        数据项名称
        <asp:DropDownList runat="server" ID="ddlItemName" DataSourceID="dsItem" DataTextField="itemText"
          AutoPostBack="true" DataValueField="itemName" AppendDataBoundItems="true" OnSelectedIndexChanged="ddlItemName_SelectedIndexChanged">
          <asp:ListItem Value="">-不限定-</asp:ListItem>
        </asp:DropDownList>
        <%--
        <asp:ImageButton runat="server" ID="btnSearch" ToolTip="检索" ValidationGroup="Search"
          ImageUrl="~/image/icon_funtion.gif" ImageAlign="AbsMiddle" OnClick="btnSearch_Click" />
        <asp:RequiredFieldValidator runat="server" ValidationGroup="Search" ControlToValidate="txtItemName" ErrorMessage="请输入检索条件"
          EnableClientScript="true" />
        --%>
      </td>
      <td align="right" valign="middle">
        <asp:ImageButton runat="server" ID="btnInsert" ToolTip="新增" ValidationGroup="Action"
          ImageUrl="~/image/add.png" ImageAlign="AbsMiddle" OnClick="btnInsert_Click" />
      </td>
    </tr>
  </table>
  <asp:GridView ID="gvDict" runat="server" DataSourceID="dsDict" PageSize="15" AllowPaging="True"
    AllowSorting="True" AutoGenerateColumns="False" Width="100%" BackColor="White"
    BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="3" DataKeyNames="itemName,itemValue"
    ForeColor="Black" GridLines="None" OnRowCommand="gvDict_RowCommand" OnRowDataBound="gvDict_RowDataBound"
    OnRowEditing="gvDict_RowEditing">
    <FooterStyle BackColor="#CCCC99" />
    <RowStyle BackColor="#F7F7DE" />
    <Columns>
      <asp:BoundField DataField="ItemName" ReadOnly="True" HeaderText="名称" SortExpression="ItemName"
        ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></asp:BoundField>
      <asp:BoundField DataField="ItemValue" ReadOnly="True" HeaderText="取值" ItemStyle-HorizontalAlign="Left"
        HeaderStyle-HorizontalAlign="Left"></asp:BoundField>
      <asp:BoundField DataField="ValueDesc" HeaderText="描述" ItemStyle-HorizontalAlign="Left"
        HeaderStyle-HorizontalAlign="Left"></asp:BoundField>
      <asp:BoundField DataField="ValueOrder" HeaderText="顺序" ItemStyle-HorizontalAlign="Left"
        HeaderStyle-HorizontalAlign="Left"></asp:BoundField>
      <%--
            <asp:BoundField DataField="ItemDefault" HeaderText="缺省值" ItemStyle-HorizontalAlign="Left"
                HeaderStyle-HorizontalAlign="Left" />
            --%>
      <asp:TemplateField HeaderText="操作">
        <ItemStyle HorizontalAlign="Right" />
        <HeaderStyle HorizontalAlign="Right" />
        <ItemTemplate>
          <asp:ImageButton ID="btnEdit" runat="server" ImageUrl="~/image/btn_edit.gif" CommandName="Edit"
            CssClass="button3" />
          <asp:ImageButton ID="btnDelete" runat="server" ImageUrl="~/image/btn_delete2.gif"
            CommandName="Delete" CssClass="button3" OnClientClick="return confirm('确定删除此数据项？');" />
        </ItemTemplate>
      </asp:TemplateField>
    </Columns>
    <PagerSettings Mode="NumericFirstLast" PageButtonCount="10" />
    <PagerStyle Font-Bold="True" HorizontalAlign="Right" CssClass="pager" />
    <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
    <AlternatingRowStyle BackColor="White" />
  </asp:GridView>
  <asp:FormView ID="fvDict" runat="server" DataSourceID="dsDict" Width="100%" Visible="False"
    OnItemInserted="fvDict_ItemInserted" OnItemUpdated="fvDict_ItemUpdated" OnItemCommand="fvDict_ItemCommand"
    OnPreRender="fvDict_PreRender" OnItemInserting="fvDict_ItemInserting" OnItemUpdating="fvDict_ItemUpdating">
    <EditItemTemplate>
      <table>
        <tr>
          <td>
            数据项名称：
          </td>
          <td>
            <asp:DropDownList runat="server" ID="ddlItemName" DataSourceID="dsItem" DataTextField="itemText"
              DataValueField="itemName" AppendDataBoundItems="true" SelectedValue='<%# Bind("itemName") %>'>
              <asp:ListItem Value="">-不限定-</asp:ListItem>
            </asp:DropDownList>
            <span class="required">*</span>
            <asp:RequiredFieldValidator runat="server" ControlToValidate="ddlItemName" ErrorMessage="数据项名称必须填写"
              EnableClientScript="true" Display="Dynamic" />
            <asp:RegularExpressionValidator runat="server" ControlToValidate="ddlItemName" ValidationExpression="^\w{1,30}$"
              ErrorMessage="数据项名称不合法" EnableClientScript="true" Display="Dynamic" />
          </td>
        </tr>
        <tr>
          <td>
            数据项取值：
          </td>
          <td>
            <asp:TextBox ID="txtItemValue" runat="server" Text='<%# Bind("itemValue") %>' Columns="30" />
            <span class="required">*</span>
            <asp:RequiredFieldValidator runat="server" ControlToValidate="txtItemValue" ErrorMessage="数据项取值必须填写"
              EnableClientScript="true" Display="Dynamic" />
          </td>
        </tr>
        <tr>
          <td>
            数据项取值描述：
          </td>
          <td>
            <asp:TextBox ID="txtValueDesc" runat="server" Text='<%# Bind("valueDesc") %>' Columns="45" />
            <span class="required">*</span>
            <asp:RequiredFieldValidator runat="server" ControlToValidate="txtValueDesc" ErrorMessage="数据项取值描述必须填写"
              EnableClientScript="true" Display="Dynamic" />
          </td>
        </tr>
        <tr>
          <td>
            数据项取值顺序：
          </td>
          <td>
            <asp:TextBox ID="txtValueOrder" runat="server" Text='<%# Bind("valueOrder") %>' Columns="5" />
            <asp:RangeValidator runat="server" ControlToValidate="txtValueOrder" Type="Integer"
              MinimumValue="0" MaximumValue="999" ErrorMessage="数据项取值顺序不合法" EnableClientScript="true"
              Display="Dynamic" />
          </td>
        </tr>
        <tr>
          <td>
            备注：
          </td>
          <td>
            <asp:TextBox ID="txtSummary" runat="server" TextMode="MultiLine" Text='<%# Bind("summary") %>'
              Columns="45" Rows="3" />
          </td>
        </tr>
      </table>
      <asp:Button ID="btnInsert" runat="server" CausesValidation="True" CommandName="Insert"
        Text="新增" CssClass="button" />
      <asp:Button ID="btnUpdate" runat="server" CausesValidation="True" CommandName="Update"
        Text="更新" CssClass="button" />
      <asp:Button ID="btnCancel" runat="server" CausesValidation="False" CommandName="Cancel"
        Text="取消" CssClass="button" />
    </EditItemTemplate>
  </asp:FormView>
</asp:Content>
